import 'package:concert_ticket_client/app/api/test_api.dart';
import 'package:concert_ticket_client/app/api/user_api.dart';
import 'package:concert_ticket_client/app/model/bo/user_model/UserModel.dart';
import 'package:concert_ticket_client/app/modules/recommend_ticket/views/recommend_ticket_view.dart';
import 'package:concert_ticket_client/app_config.dart';
import 'package:flutter/material.dart';
import 'package:concert_ticket_client/app/model/resp/Resp.dart';
import 'package:get/get.dart';

import '../controllers/home_controller.dart';
import 'package:concert_ticket_client/app/routes/app_pages.dart';

class HomeView extends GetView<HomeController> {
  HomeView({super.key});
  List<Widget> tabs = [
    Tab(text: '推荐门票'),
    Tab(text: '排行榜'),
    Tab(text: '分类'),
  ];
  TabBarView tabBarView = TabBarView(
    children: [
      RecommendTicketView(),
      Text('排行榜'),
      Text('分类'),
    ],
  );
  @override
  Widget build(BuildContext context) {
    //  定义搜索框
    Widget searchBar = TextField(
      decoration: InputDecoration(
        hintText: '请输入关键字',
        suffixIcon: IconButton(
          icon: Icon(Icons.search),
          onPressed: () {
            Get.toNamed(Routes.TICKET_SEARCH);
          },
        ),
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(6),
        ),
        constraints: BoxConstraints(maxHeight: 40), // 最小高度

      ),
      textAlignVertical: TextAlignVertical.bottom,
      //  监听回车事件
      onSubmitted: (value) {
        Get.toNamed(Routes.TICKET_SEARCH);
      },

    );
    return Scaffold(
      appBar: AppBar(
        title: searchBar,
      ),
      body: DefaultTabController(
        length: tabs.length,
        child: Scaffold(
          appBar: AppBar(
            toolbarHeight: 0,
            bottom: TabBar(
              tabs: tabs,
            ),
          ),
          body: tabBarView,
        ),
      ),
    );
  }
}
